package com.bodacn.keypoint.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.bodacn.keypoint.R;
import com.bodacn.keypoint.bean.ODetail;


import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * Created by KangJunjie on 2020/6/18.
 */
public class DetailAdapter extends BaseAdapter {
    private Context context;
    private List<ODetail> dataBeans;

    public DetailAdapter(Context context, List<ODetail> beanList) {
        this.context = context;
        this.dataBeans = beanList;
    }

    @Override
    public int getCount() {
        return dataBeans.size();
    }

    @Override
    public Object getItem(int position) {
        return dataBeans.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder viewHolder;
        if (convertView == null) {
            convertView = LayoutInflater.from(context).inflate(R.layout.lv_detail_item, parent, false);
            viewHolder = new ViewHolder(convertView);
            convertView.setTag(viewHolder);
        } else {
            viewHolder = (ViewHolder) convertView.getTag();
        }
        viewHolder.tvHetonghao.setText(dataBeans.get(position).getOrderNo());
        viewHolder.tvGanghao.setText(dataBeans.get(position).getVatNo());
        viewHolder.tvKuweihao.setText(dataBeans.get(position).getPlaceNo());
        viewHolder.tvMianliaomingcheng.setText(dataBeans.get(position).getBaleName());
        viewHolder.tvMianliaotioma.setText(dataBeans.get(position).getFabricNo());
        viewHolder.tvPihao.setText(dataBeans.get(position).getVolumeNo());
        viewHolder.tvShuliang.setText(dataBeans.get(position).getNumber());
        viewHolder.tvSongbujahao.setText(dataBeans.get(position).getLooseRackNo());


        return convertView;
    }

    class ViewHolder {
        @BindView(R.id.tv_kuweihao)
        TextView tvKuweihao;
        @BindView(R.id.tv_songbujahao)
        TextView tvSongbujahao;
        @BindView(R.id.tv_mianliaotioma)
        TextView tvMianliaotioma;
        @BindView(R.id.tv_hetonghao)
        TextView tvHetonghao;
        @BindView(R.id.tv_mianliaomingcheng)
        TextView tvMianliaomingcheng;
        @BindView(R.id.tv_ganghao)
        TextView tvGanghao;
        @BindView(R.id.tv_pihao)
        TextView tvPihao;
        @BindView(R.id.tv_shuliang)
        TextView tvShuliang;

        ViewHolder(View view) {
            ButterKnife.bind(this, view);
        }
    }
}
